#ifndef __DBMANAGER_H__
#define __DBMANAGER_H__

#define DBAPP DBManager::getInstance()

#include <iostream>
#include <mutex>
#include <mysql.h>

class DBManager
{
public:
    static DBManager* getInstance();
    void init();

    ~DBManager();

    /**
     * 1. 实现注册、登录功能
     *  1. 查询用户
     *  2. 插入用户数据
    */
   bool isUserExist(const std::string user);
   bool registerUser(const std::string user, 
                     const std::string passwd, 
                     const std::string phone, 
                     const std::string email, 
                     const std::string data);
private:
    static DBManager* self;
    static std::mutex self_mutex;

    MYSQL *sql_conn;

private:
    DBManager(/* args */);
};


#endif //__DBMANAGER_H__